package tag;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;

public class Say extends SimpleTagSupport {
	//引擎将jsp中的info值赋给info，再调用doTag()方法
	private String info;
	private int num;
	public Say() {
		System.out.println("default constructor say");
	}
	public String getInfo() {
		System.out.println("getinfo");
		return info;
	}

	public int getNum() {
		System.out.println("getnum");
		return num;
	}

	public void setInfo(String info) {
		System.out.println("setinfo");
		this.info = info;
	}

	public void setNum(int num) {
		System.out.println("setnum");
		this.num = num;
	}

	@Override
	public void doTag() throws JspException, IOException {
		PageContext pc = (PageContext)getJspContext();//SimpleTagSupport
		JspWriter out = pc.getOut();
		for(int i=0;i<num;i++){
			out.println(info);//+<br>
		}
	}
	
}
